<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/email_list/db" VERSION="20070511" COMMENT="XMLDB file for Moodle email"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
  <TABLES>
    <TABLE NAME="block_email_list_preference" COMMENT="Global preferences for Email" NEXT="block_email_list_mail">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="trackbymail"/>
        <FIELD NAME="trackbymail" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="userid" NEXT="marriedfolders2courses"/>
        <FIELD NAME="marriedfolders2courses" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="trackbymail" NEXT="emailrefreshrate"/>
        <FIELD NAME="emailrefreshrate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="600" SEQUENCE="false" PREVIOUS="marriedfolders2courses"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_preference" NEXT="userid"/>
        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary"/>
      </KEYS>
    </TABLE>
    <TABLE NAME="block_email_list_mail" COMMENT="All mails are stored in this table" PREVIOUS="block_email_list_preference" NEXT="block_email_list_send">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="course"/>
        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="respondedid"/>
        <FIELD NAME="respondedid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="course" NEXT="subject"/>
        <FIELD NAME="subject" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="respondedid" NEXT="timecreated"/>
        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="subject" NEXT="body"/>
        <FIELD NAME="body" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="timecreated"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_mail" NEXT="userid"/>
        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary" NEXT="course"/>
        <KEY NAME="course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id" PREVIOUS="userid"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="subject" UNIQUE="false" FIELDS="subject" NEXT="timecreated"/>
        <INDEX NAME="timecreated" UNIQUE="false" FIELDS="timecreated" PREVIOUS="subject" NEXT="coursemailid"/>
        <INDEX NAME="coursemailid" UNIQUE="false" FIELDS="course, id" PREVIOUS="timecreated"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_email_list_send" COMMENT="Mail user send, type and it is readed" PREVIOUS="block_email_list_mail" NEXT="block_email_list_folder">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="course"/>
        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="mailid"/>
        <FIELD NAME="mailid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="course" NEXT="type"/>
        <FIELD NAME="type" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="to" SEQUENCE="false" PREVIOUS="mailid" NEXT="readed"/>
        <FIELD NAME="readed" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="type" NEXT="sended"/>
        <FIELD NAME="sended" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" COMMENT="This field only is show when send mail by type draft, who it is value is zero" PREVIOUS="readed" NEXT="answered"/>
        <FIELD NAME="answered" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="sended" NEXT="toext"/>
        <FIELD NAME="toext" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="answered" />
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_send" NEXT="userid"/>
        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary" NEXT="course"/>
        <KEY NAME="course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id" PREVIOUS="userid" NEXT="mailid"/>
        <KEY NAME="mailid" TYPE="foreign" FIELDS="mailid" REFTABLE="email_mail" REFFIELDS="id" PREVIOUS="course"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="readed" UNIQUE="false" FIELDS="readed" NEXT="type"/>
        <INDEX NAME="type" UNIQUE="false" FIELDS="type" PREVIOUS="readed" NEXT="sended"/>
        <INDEX NAME="sended" UNIQUE="false" FIELDS="sended" PREVIOUS="type"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_email_list_folder" COMMENT="All Folders for store mails. isparenttype content only type of parents folders. There are inbox" PREVIOUS="block_email_list_send" NEXT="block_email_list_subfolder">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="course"/>
        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="name"/>
        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="course" NEXT="timecreated"/>
        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="name" NEXT="isparenttype"/>
        <FIELD NAME="isparenttype" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" PREVIOUS="timecreated"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_folder" NEXT="userid"/>
        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary" NEXT="course"/>
        <KEY NAME="course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id" PREVIOUS="userid"/>
      </KEYS>
      <INDEXES>
        <INDEX NAME="isparenttype" UNIQUE="false" FIELDS="isparenttype"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_email_list_subfolder" COMMENT="SubFolders for one folder for store mails" PREVIOUS="block_email_list_folder" NEXT="block_email_list_foldermail">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="folderparentid"/>
        <FIELD NAME="folderparentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="folderchildid"/>
        <FIELD NAME="folderchildid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="folderparentid"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_subfolder" NEXT="parent"/>
        <KEY NAME="parent" TYPE="foreign" FIELDS="folderparentid" REFTABLE="email_folder" REFFIELDS="id" PREVIOUS="primary" NEXT="child"/>
        <KEY NAME="child" TYPE="foreign" FIELDS="folderchildid" REFTABLE="email_folder" REFFIELDS="id" PREVIOUS="parent"/>
      </KEYS>
    </TABLE>
    <TABLE NAME="block_email_list_foldermail" COMMENT="Mails of one folder" PREVIOUS="block_email_list_subfolder" NEXT="block_email_list_filter">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="mailid"/>
        <FIELD NAME="mailid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="folderid"/>
        <FIELD NAME="folderid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="mailid"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_foldermail" NEXT="mailid"/>
        <KEY NAME="mailid" TYPE="foreign" FIELDS="mailid" REFTABLE="email_mail" REFFIELDS="id" PREVIOUS="primary" NEXT="folderid"/>
        <KEY NAME="folderid" TYPE="foreign" FIELDS="folderid" REFTABLE="email_folder" REFFIELDS="id" PREVIOUS="mailid"/>
      </KEYS>
      <INDEXES>
      	<INDEX NAME="folderid-mailid" UNIQUE="false" FIELDS="folderid, mailid"/>
      </INDEXES>
    </TABLE>
    <TABLE NAME="block_email_list_filter" COMMENT="Filter mail for one folder" PREVIOUS="block_email_list_foldermail" NEXT="block_email_list_lists">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="folderid"/>
        <FIELD NAME="folderid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="rules"/>
        <FIELD NAME="rules" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="folderid"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_filter"/>
      </KEYS>
    </TABLE>
    <TABLE NAME="block_email_list_lists" COMMENT="mail lists" PREVIOUS="block_email_list_filter" NEXT="block_email_list_members">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="listname"/>
        <FIELD NAME="listname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="owner"/>
        <FIELD NAME="owner" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="listname"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_list_lists" NEXT="owner"/>
        <KEY NAME="owner" TYPE="foreign" FIELDS="owner" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary"/>
      </KEYS>
    </TABLE>
    <TABLE NAME="block_email_list_members" COMMENT="mail lists" PREVIOUS="block_email_list_lists">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="listid"/>
        <FIELD NAME="listid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="userid"/>
        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="listid" NEXT="extaddr"/>
        <FIELD NAME="extaddr" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="userid"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for email_list_members" NEXT="listid"/>
        <KEY NAME="listid" TYPE="foreign" FIELDS="listid" REFTABLE="block_email_list_lists" REFFIELDS="id" PREVIOUS="primary" NEXT="userid"/>
        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="listid"/>
      </KEYS>
    </TABLE>
  </TABLES>
</XMLDB>